package AoppractiseDemo.aop;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Aspect//切面
public class myAdvice {  //通知类
//切入点
//@Pointcut("execution(void AoppractiseDemo.dao.bookdao.update(*))")  不能用，必须有参数
//@Pointcut("execution(void AoppractiseDemo.dao.bookdao.update())")
//@Pointcut("execution(void AoppractiseDemo.dao.bookdao.update())")
@Pointcut("execution(void AoppractiseDemo.dao.bookdao.update())")
     private void pt(){}

//环绕通知
@Around("pt()")
    public void  methodupdate(ProceedingJoinPoint pjp) throws Throwable{
        Long startTime=System.currentTimeMillis();
        for(int i=0;i<10000;i++){
          pjp.proceed();    //调用原始方法后，看原始方法是否有返回值
        }
        Long endTime=System.currentTimeMillis();
        Long totalTime=endTime-startTime;
        System.out.println("执行万次消耗时间:"+totalTime);
    }

   // @AfterThrowing("pt()")   //抛出异常之后
//


}
